package com.acme.task1;

public class Calculator {
	static final String MES_ARGS_AMOUNT_MISMATCH = "Amount of arguments is mismatch";
	static final String MES_ARGS_NOT_NUMBER = "One or both arguments of operation are not numbers";
	static final String MES_INVALID_OPERATION = "Invalid operation";
	
	public static void main(String[] args) {
		if (args.length != 3) {
			System.out.println(MES_ARGS_AMOUNT_MISMATCH);
			return;
		}

		double operand1 = 0, operand2 = 0, result = Double.NaN;
		char operation;
		
		try {
			operand1 = Double.parseDouble(args[0]);
			operand2 = Double.parseDouble(args[2]);
			operation = args[1].charAt(0);
			
			result = Solve(operand1, operation, operand2);
			
			System.out.println(result);
			
		} catch (NumberFormatException ex) {
			System.out.println(MES_ARGS_NOT_NUMBER);
		}
	}
	
	static double Solve(double operand1, char operation, double operand2) {
		double result = Double.NaN;
			
		switch (operation) {
		case '+':
			result = operand1 + operand2;
			break;
		case '-':
			result = operand1 - operand2;
			break;
		case '/':
			result = operand1 / operand2;
			break;
		case '*':
			result = operand1 * operand2;
			break;
			default:
				System.out.println(MES_INVALID_OPERATION);
		}
		
		return result;
	}
}
